"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const Global_1 = require("../models/Global");
async function default_1(call) {
    let op = await Global_1.Global.collection('Rank').findOne({ openid: call.req.rank.openid });
    if (!op) {
        // 不存在记录则添加
        await Global_1.Global.collection('Rank').insertOne({
            ...call.req.rank,
            createTime: new Date(),
            updateTime: new Date()
        });
    }
    else {
        // 存在记录则修改
        await Global_1.Global.collection('Rank').updateOne({
            openid: call.req.rank.openid
        }, {
            $set: {
                updateTime: new Date()
            },
            $inc: {
                win: 1,
                kill: call.req.rank.kill
            }
        });
    }
    call.succ({});
}
exports.default = default_1;
